<!DOCTYPE html>
<html lang='en'>

<head>
	<meta charset='utf-8' />
	<title>安装vue</title>
	<!-- <script src='https://cdn.jsdelivr.net/npm/vue/dist/vue.js'></script> -->
	<script src='../js/vue.js'></script>
</head>

<body>
	<div id='app'>

		<h1>今天天气很{{info}}</h1>
		<button @click="change">点击切换天气</button>

	</div>



	<script>
		var vue = new Vue({
			el: '#app',
			data: {
				wheather: true,
			}, methods: {
				change(event) {
					this.wheather = !this.wheather
				}
			}, computed: {
				info: {
					/* 当获取 info 变量时 或依赖发生改变会执行get 函数 */
					get() {
						return this.wheather ? '炎热' : '凉爽'
					},
					/* 当修改 info 变量时会执行set 函数 */
					set() {
						console.log("aaa")
					}

				}
			}, watch: {
				info: {
					immediate: true,//初始化时就调用一次handler函数
					handler(newvalue, oldvalue) {
						console.log('info我被监视了' + newvalue + oldvalue)
					}

				}
			}


		});
		vue.$watch('wheather', {
			immediate: true,//初始化时就调用一次handler函数
			handler(newvalue, oldvalue) {
				console.log('wheather我被监视了' + newvalue + oldvalue)
			}
		})

	</script>
</body>

</html>